package net.comm.user.db;


import java.sql.ResultSet;
import java.sql.SQLException;


import net.comm.user.bean.BaseContacts;
import net.comm.user.bean.BaseDetails;
import net.comm.user.bean.BaseUsers;
import net.comm.util.StringUtil;

import org.apache.log4j.Logger;
import org.sakaiproject.db.api.SqlReader;

public class DbUsersService implements SqlReader
{
	static Logger logger = Logger.getLogger(DbUsersService.class.getName());

	/**
	 * Read from the result one set of fields to create a Resource.
	 * 
	 * @param result
	 *        The Sql query result.
	 * @return The Resource object.
	 */
	public Object readSqlResultRecord(ResultSet result)
	{
		try
		{
			
			int  	userID = result.getInt(1);		//会员ID
			String  nick = StringUtil.getValue(result.getString(2));			//昵称
			String  email = StringUtil.getValue(result.getString(3));		//Email
			String  password = StringUtil.getValue(result.getString(4));		//
			String  status = StringUtil.getValue(result.getString(5));		//状态
			String  type = StringUtil.getValue(result.getString(6));			//类型
			String  ctime = StringUtil.getValue(result.getString(7));		//注册时间
			int  loginCnt = result.getInt(8);			//登录次数
			String  ltime = StringUtil.getValue(result.getString(9));		//上次登录时间
			String  online = StringUtil.getValue(result.getString(10));		//上次登录时间
			String  mtime = StringUtil.getValue(result.getString(11));		//最后修改时间
			String  remark = StringUtil.getValue(result.getString(12));		//备注

			// create the Resource from these fields
			return new BaseUsers( userID, nick, email, password, status, type, ctime, loginCnt, ltime,
					online, mtime, remark );
		}
		catch (SQLException e)
		{
			logger.error("数据层读取表记录失败");			
			return null;
		}
		
	}
}
